Programmable optical character recognition system

ABSTRACT

An improved Optical Character Recognition System (OCRS) is taught using programmable logic devices to implement the mathematical algorithms that are used to make the black/white and related decisions. The programmable logic devices include, but are not limited to, Programmable Read Only Memories (PROMs), Erasable Read Only Memories (EPROMs), Electrically Erasable Programmable Read Only Memories (EEPROMs), and Field Programmable Logic Arrays (FPLAs).

This is a continuation of U.S. patent application Ser. No. 598,747 filed Oct. 17, 1990, now U.S. Pat. No. 5,042,076, which was a continuation of U.S. patent application Ser. No. 279,333 filed Dec. 2, 1988, now abandoned, which was a continuation of U.S. patent application Ser. No. 110,935, filed Oct. 20, 1987, now abandoned.

FIELD OF THE INVENTION

This invention relates to Optical Character Recognition Systems (OCRS) of the type that read printed or typed data.

BACKGROUND OF THE INVENTION

Optical Character Recognition Systems (OCRS) have become increasingly useful for reading data in a wide variety of applications. Portable OCRS are used by store clerks to read pricing and inventory numbers from the price tags of merchandise. Stationary OCRS are used to sort the large volumes of incoming mail received by banks, credit institutions, taxing authorities, postal services, and department stores and to store information from other documents, in digital form, in a memory device. Such stationary OCRS must be capable of reading information on the envelopes or other documents at a very fast rate with a high degree of accuracy.

The vast majority of data that is read by an OCRS is comprised of a black character--of varying shades--against a white background--also of varying shades. The data may be comprised of other, colored data or backgrounds other than white. However, the data will be dark or "black" with respect to the lighter or "white" background. For the purposes of this application, the term "black" will be used to refer to the data, and the term "white" will be used to refer to the background, it being understood that any other colors may be used as long as the data is dark with respect to a lighter background.

In order for an OCRS to recognize or read any given character, it is crucial that the OCRS accurately distinguish the color black from the color white. The OCRS then match the shape or outline of the black characters with a library cf known, stored characters to determine which character has been read.

There are several popular types of OCRS. One type uses an array of photoelectric sensors or pixels to scan a line of print. Each sensor emits an analog signal corresponding to the amount of light reflected by the scanned paper back to the sensor. These analog signals are converted into a digital form of `ones` and `zeros` corresponding to the colors `white` and `black`. The purpose of this conversion is to create a high contrast, digital image of the signal for presentation to the recognition unit of the OCRS.

The determination as to whether a particular pixel is sensing the color "black" or the color "white" is difficult due to the many different shades of "black" and "white" that appear in typed or printed form. Indeed, the "blackness" sensed by one pixel may differ from that sensed by an adjacent pixel even thought both pixels are sensing the same character. Also, the same pixel may sense different degrees of `blackness` or `whiteness` in the same document or in different documents. These variations are caused by unevenness in the printing of the characters by differences in the sensors themselves and by uneveness of the surface or the position of the document being read and differences in the documents themselves.

Many ways have been developed to make the decision as to whether a pixel is sensing a portion of a black character or a portion of a white background. One way is to compare the value sensed by the pixel with the values sensed by surrounding pixels to determine its relative "blackness" or "whiteness".

Regardless of which procedure is used, this crucial "black/white" decision often requires the use of a series of decision points or algorithms. These algorithms are often very complex. Regardless of which algorithm is used, there will always be some data that is not readable or is incorrectly read by the OCRS.

To improve the reading accuracy, manufacturers of OCRS are continually re-evaluating and changing these decision algorithms in an attempt to achieve higher degrees of accuracy. Unfortunately, it is often difficult and expensive to change the decision algorithms since they are typically implemented with discrete logic connected by printed wiring. To change the algorithms requires a modification to the printed wiring using etch cut and jumper techniques if the change is simple or re-layout of the printed circuit board if the change is extensive. It is therefore desirable to decrease the time and expense involved in changing the black/white decision algorithms.

SUMMARY OF THE INVENTION

An improved Optical Character Recognition System (OCRS) is described using programmable logic devices to implement the mathematical algorithms that are used to make the black/white and related decisions. The programmable logic devices include, but are not limited to, Programmable Read Only Memories (PROMs), Erasable Read Only Memories (EPROMs), Electrically Erasable Programmable Read Only Memories (EEPROMs), and Field Programmable Logic Arrays (FPLAs).

In a preferred OCRS embodiment, the programmable logic devices are used to implement the following functions:

(1) to analyze how much change, if any, should be made to the upper reference voltage of an Analog-to-Digital Converter;

(2) to establish an appropriate white background value in the horizontal direction for each pixel so that horizontally ordered differences may be normalized;

(3) to produce a modulated signal corresponding to the scanned data by comparing the pixel value with the background value and outputting a value proportional to their relationship; and

(4) to provide a dynamic threshold value used to determine whether a given pixel is black or white.

The above list is merely representative of a few uses of programmable logic devices to implement algorithms in an OCRS. The use of programmable logic devices to implement other algorithms as well is still within the contemplated scope of the present invention.

It is a feature of the present invention to provide an improved OCRS that enables decision algorithms to be readily and inexpensively changed.

It is another feature of the present invention to use programmable logic devices to implement decision algorithms in an OCRS.

These and other features and applications of the present invention will be apparent from the detailed description.

IN THE DRAWINGS

FIG. 1 is a flow diagram of the Array circuit and the Vertical Automatic Gain Control (VAGC) circuit in an OCRS according to the present invention.

FIG. 2 is a flow diagram of a Horizontal Automatic Gain Control (HAGC) circuit in an OCRS according to the present invention.

FIG. 3 is a flow diagram of a Black/White (B/W) decision circuit in an OCRS according to the present invention.

DETAILED DESCRIPTION

A preferred embodiment of an OCRS according to the present invention consists of four printed circuit (PC) boards and the optical equipment needed to capture the data to be read using a 1 by 512 element CCD array. The PC boards are identified as: (1) the Array circuit (FIG. 1); (2) the Video Automatic Gain Control (VAGC) circuit (FIG. 1); (3) the Horizontal Automatic Gain Control (HAGC) circuit (FIG. 2); and (4) the Black/White (B/W) decision circuit (FIG. 3).

A brief description of these circuits is as follows.

The Array circuit contains the CCD array chip, an amplifier for adjusting the gain and the balance of the odd and even video signals, and TTL-to-MOS clock/timing generators for driving the CCD array.

The VAGC circuit contains the logic to provide the basic timing signals to all four circuits. It also converts the analog video signal sensed by the Array circuit into 6-bit digital values that are normalized. The VAGC circuit also assigns a value of 63 for the maximum white (background) value encountered in one scan of the data being read.

The HAGC circuit calculates the maximum white (background) value sensed by each pixel in a horizontal direction. Additional circuitry converts the 6-bit digital video value for each pixel produced by the VAGC circuit, to a 4-bit value that represents the proportional relationship of the 6-bit value to its associated background value.

The B/W circuit calculates the average of the 25 pixels in a 5 by 5 matrix surrounding the test pixel. This average value is compared to the test pixel's value, and a "black/white" decision is made. If the test pixel's value is less than the average value, the test pixel is called "black".

As more fully discussed below, the mathematical computations made in the VAGC, HAGC, and B/W circuits are performed by using programmable logic devices. These devices include, but are not limited to, Programmable Read Only Memories (PROMs), and Field Programmable Logic Arrays (FPLAs). This feature allows the mathematical algorithms to be changed and enhanced without modifying the individual circuits. The programmable logic device is removed and replaced with a new one that contains the new algorithm. This feature also permits non-linear algorithms to be used.

I. The Array Circuit

The power and three input signals are supplied to the Array circuit from the VAGC circuit via a 26 conductor flat ribbon cable. The analog video signal is output from the Array Circuit to the VAGC circuit via a 50 ohm coaxial cable.

Referring to FIG. 1, the three input signals are converted from TTL level to MOS level logic for driving CCD array 1.

Three terminal voltage regulators (not shown) are mounted on the Array Circuit to provide voltages other than ±12 volts.

There are two video output lines from the Array Circuit, odd cells and even cells. These video output signals are a series of voltage levels which represent the amount of light each cell has collected during the scan interval. The wave form is a 50% duty cycle pulse for each cell on both the odd and even drain lines. The 50% duty cycle pulses are 180 degrees out of phase, and are combined into one amplifier creating a signal (double rate) video output line.

Analog amplifier 4 has adjustments for changing the gain and balancing the two video output signals transmitted via lines 2 and 3. The analog video level should be adjusted via the balance adjustment for minimum odd/even noise at the black level. The gain should be adjusted for a 1.0 volt modulation between the dark reference cells and the white paper or background. The DC range of this 1.0 volt modulation should be -1.5 volts to -0.5 volts at the coaxial cable.

II. The VAGC Circuit

This circuit generates the basic clock signals for the OCRS and converts the analog video signal into a 6-bit digital value.

The basic oscillator frequency is generated by a 27 MHz oscillator when the transporter that transports documents past the scanner is not running, and a phased lock looped circuit which tracks the belt speed encoder pulses when the transporter is running. This switcher is controlled by a transporter motor-on signal.

FPLA 11 used in the VAGC circuit analyzes the results of two accumulators 8a and 8b to determine how much change, if any, should be made to the upper reference voltage of an Analog-to-Digital converter 6.

The purpose of this function is to ensure that the whitest pixel elements within each scan will be assigned a value of 63 by converter 6 (for a 6-bit converter), regardless of the relative brightness of those white pixels.

Referring again to FIG. 1, the analog video signal is first sent to a clamping circuit 5 that sets the dark reference cell level to -1.0 volts. This same -1.0 volt reference is used to set the bottom reference of A/D converter 6. This causes the 6-bit A/D output to have a decimal weight of "0" for black.

The value of every pixel element is monitored at the output of Analog to Digital converter 6 by a video level decoder 7 during each scan interval. The number of pixel elements having the value of 62 and 63 are accumulated by separate, pre-loadable, accumulators 8a and 8b. Accumulator 8a is incremented when a value of 62 occurs. Accumulator 8b is incremented when a value of 63 occurs. Each accumulator can be preset to look for a minimum value. When the minimum value is reached, it ceases to accumulate and outputs a Terminal Count (TC) bit.

The count 63 accumulator 8b should be preset to a larger value than count 62 accumulator 8a, typically 32 for accumulator 8b and 4 for accumulator 8a.

At the end of the scan interval the final value and "Terminal Count bit" of each of these accumulators is analyzed by FPLA 11.

In a preferred embodiment, the following decision points or algorithms may be used to determine whether the background or white level will be changed:

    ______________________________________                                                     FINAL                                                              ACCUMULATOR VALUE    TC PRESET  GAIN CHANGE                                    ______________________________________                                         count 63    1111 1111                                                                               yes                                                       (accumulator 8b)                                                               count 62    1111 1111                                                                               yes        no change                                      (accumulator 8a)                                                               count 63    1111 1111                                                                               yes                                                       &                                                                              count 62    1111 1110                                                                               no         decrease by 1                                  count 62    1111 110x                                                                               no         decrease by 2                                  count 62    1111 10xx                                                                               no         decrease by 4                                  count 62    1111 0xxx                                                                               no         decrease by 8                                  count 62    1110 xxxx                                                                               no         decrease by 16                                 count 62    110x xxxx                                                                               no         decrease by 16                                 count 62    10xx xxxx                                                                               no         decrease by 16                                 count 62    0xxx xxxx                                                                               no         decrease by 16                                 count 63    1111 1110                                                                               no         increase by 1                                  count 63    1111 110x                                                                               no         increase by 2                                  count 63    1111 10xx                                                                               no         increase by 4                                  count 63    1111 0xxx                                                                               no         increase by 8                                  count 63    110x xxxx                                                                               no         increase by 16                                 count 63    10xx xxxx                                                                               no         increase by 16                                 count 63    0xxx xxxx                                                                               no         increase by 16                                 ______________________________________                                          NOTE: "x" means the value does not matter.                               

The amount and direction of the change derived from the analysis by FPLA 11 is sent to up/down counter 9 which in turn drives Digital to Analog converter (D/A) 10. Converter 10 generates an upper reference voltage for the A/D converter 6. The upper reference voltage is 0.0 volts if the counter value of up/down counter 9 is 0, and -0.5. volts if the counter value is 255.

The determination to adjust the upper reference voltage of A/D converter 6 is made at the end of each scan. The adjustment, if any, is made during the times that the document passes the 16 inactive cells of array 1 in each scan.

The video output of the VAGC circuit is a 6-bit digital value, where the whitest cell value is "63" and the darkest cell value is "0" for documents having a normalized reflectance range of 1.0 to 0.5 (assuming 1.0=white, and 0.0=black).

The determinations made by the VAGC circuit may be modified by changing the preset values of accumulators 8a and 8b, and by changing the contents of FPLA 11 thereby affording dynamic gain control of the OCRS as a function of the information collected during the previous scan.

III. HAGC Circuit

There are three PROMS used in this circuit which provide the computational power. Referring to FIG. 2, a first PROM 14 selects which of five adjacent pixel values in the vertical direction is whitest and establishes it as the new background value (A). A second PROM 15 compares this new background value with the previous background value (B) calculated for that same vertical location and outputs a present background value (D). A third PROM 16 produces a 4-bit (0-15) video level which is proportional to the ratio of the background calculation for each pixel and the present 6-bit (0-63) video level of that pixel.

1. New Background Value Calculation

The PROM used in this subcircuit compares the present determination of the background (white) value with the background value established for that same pixel during the previous scan.

The purpose of this function is to establish an appropriate white background value in the horizontal direction for each pixel so that horizontally ordered differences can be normalized out of the video signals. The output from this subcircuit is a 6-bit background value for each signal.

Referring to FIG. 2, the present background value for a pixel element is derived by testing the values of the pixel elements located in register 12 using comparators 13a through 13f. PROM 14 is used to select the highest of the values (most white) as the present background value.

This present background value is compared by PROM 15 to the previous background value read from Random Access Memory (RAM) 17 that was generated for that same pixel element during the prior scan.

A "new" background value is calculated by PROM 15 according to the following algorithm:

    ______________________________________                                         ASSUME:                                                                        (present background) =                                                                            A                                                           (previous background) =                                                                           B                                                           (new background) = D                                                           (accumulator) =    C                                                           IF:  A > B then D =    (A + B)/2; set C = 3                                    A < B and C > 0 then D =                                                                          B; set C = C - 1                                            A < B and C = 0 then D =                                                                          B - 1                                                       ______________________________________                                    

2. Modulation Enhancement

The modulation enhancement PROM 16 converts the 6-bit background value and the current 6-bit video signal value into a 4-bit proportional value.

The purpose of this function is to produce maximum modulation in the video signal.

In a preferred embodiment, a 6-bit pixel value that is equal to, or greater than, the background value is converted to a 4-bit value of 15. A 6-bit pixel value that is less than the previous background value is converted to a 4-bit value (0-15) proportional to the 6-bit video value background value.

The mathematical algorithms resident within the any of PROMS may be linear or non-linear and are easily modified to optimize system performance without re-working the printed circuit board.

IV. Black/White Decision Circuit

The function of this circuit is to compare the value of the center pixel with those of the 24 pixels that surround it in a 5×5 matrix, and the previous value of the center pixel. This is accomplished by adding up the 4-bit values of the surrounding 24 pixels and the previous value for the center pixel, and comparing that "area sum" to 25 times the value of the center pixel. If the area sum is greater than 25 times the center cell, then the center pixel is call "black". If the area sum is less than 25 times the center pixel, the center pixel is called "white".

Referring now to FIG. 3, the 4-bit value for each pixel is loaded into RAM buffers 18a-18f to accumulate five complete scans of data. Data for the same pixel element from five scans is loaded into latches 19a-19f, combined into a 5×5 area sum by adders 22a-22d, and then loaded in latch 23.

The decision to set a particular pixel to a 1-bit value (black=1, or white=0) is made by comparing, in PROM 24, the 4-bit value of that pixel with the combined sum of a 5×5 matrix of pixels whose center is that particular pixel. Included as part of this decision is the 1-bit value of the previous pixel.

The actual computation are defined by the mathematical algorithm resident within PROM 24. It may have linear or non-linear functions that are easily modified to optimize performance without reworking the printed circuit board. 

What is claimed is:
 1. Optical character recognition apparatus responsive to data on a scanned document appearing in various shades of grey on a light background to determine whether an individual pixel element in an array of pixel elements covering the document represents data or background, comprising:a vertical automatic gain control circuit for generating a normalized digital signal value for each pixel element relative to the digital signal values of all other pixel elements in a scan; a horizontal automatic gain control circuit receiving the normalized digital signal values for each pixel element in a given scan and generating a background signal value for a scan based upon the present normalized digital signal values and the normalized digital signal values from a previous scan; a modulation enhancement circuit receiving and comparing the normalized digital signal value and the scan background signal value for each pixel element and outputting a proportional digital signal value for each pixel element; and a black/white decision making circuit receiving the generated proportional digital signal values or each pixel in a scan and producing an output identifying each pixel element in a scan as containing data or background by comparing the proportional signal value of a selected pixel with a summed signal value determined by adding the proportional signal values of each pixel in a predetermined pixel matrix including the selected pixel together with the proportional signal value of the selected pixel from a previous scan.
 2. Optical character recognition apparatus as in claim wherein the modulation enhancement circuit converts the normalized signal value to a present value for output as the proportional signal value if the normalized signal value exceeds the scan background signal value, and converts the normalized signal value to a value proportional to the scan background signal value for output as the proportional signal value if the normalized signal value is less than the scan background signal value.
 3. Optical character recognition apparatus as in claim 1 wherein the predetermined pixel matrix is a matrix having "n" elements including the selected pixel.
 4. Optical character recognition apparatus as in claim 3 wherein the pixel matrix is a square matrix with the selected pixel at the center of the matrix.
 5. Optical character recognition apparatus as in claim 3 wherein the black/white decision making circuit selects "black" indicating data if the summed signal value is greater than times the proportional signal value for the selected pixel and "white" indicating background if the summed signal value is less than n times the proportional signal value for the selected pixel.
 6. Optical character recognition apparatus responsive to data on a scanned document appearing in various shades of grey on a light background to determine whether an individual pixel element in an array of pixel elements covering the document represents data or background, comprising:a vertical automatic gain control circuit for generating a normalized digital signal value for each pixel element on a scan by scan, document by document basis relative to the digital signal values of all other scanned pixel elements; a horizontal automatic gain control circuit receiving the normalized digital signal values for each pixel element in a given scan and generating a background signal value for a scan based upon the normalized digital signal values for the present scan and the normalized digital signal values from a previous scan; a modulation enhancement circuit receiving and comparing the normalized digital signal value and the scan background signal value for each pixel element and generating a proportional digital signal value for each pixel element; and a black/white decision making circuit receiving the generated proportional digital signal values of each pixel in a scan and producing an output identifying each pixel element in a scan as containing data or background by comparing the proportional signal value for a selected pixel with the proportional signal values of a predetermined set of adjacent pixels and the proportional signal value for the selected pixel from a previous scan.
 7. Optical character recognition apparatus as in claim 6 wherein the modulation enhancement circuit converts the normalized signal value to a preset value for output as the proportional signal value if the normalized signal value exceeds the scan background signal value, and converts the normalized signal value to a value proportional to the scan background signal value for output as the proportional signal value if the normalized signal value is less than the scan background signal value.
 8. Optical character recognition apparatus as in claim 6 wherein the black/white decision making circuit compares proportional signal value of the selected pixel with a summed signal value calculated by adding the proportional signal values of each pixel in the set of adjacent pixels together with the proportional signal value of the selected pixel from a previous scan.
 9. Optical character recognition apparatus as in claim 8 wherein the predetermined set of adjacent pixels has "n" elements including the selected pixel.
 10. Optical character recognition apparatus as in claim 9 wherein the pixel set is a matrix.
 11. Optical character recognition apparatus as in claim 10 wherein the matrix is a square matrix with the selected pixel at the center of the matrix.
 12. Optical character recognition apparatus as in claim 10 wherein the black/white decision making circuit selects "black" indicating data if the summed signal value is greater than n times the proportional signal value for the selected pixel and "white" indicating background if the summed signal value is less than n times the proportional signal value for the selected pixel. 